/* Global styles and reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Comic Sans MS', 'Arial Rounded MT Bold', cursive, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
    user-select: none;
}

/* Main container - adapts to iframe or standalone */
#mainContainer {
    width: 100%;
    height: 450px; /* Default for iframe */
    position: relative;
    background: linear-gradient(to bottom, #87CEEB 0%, #98D8E8 100%);
    overflow: hidden;
}

/* Standalone mode - uses 90vh */
body.standalone #mainContainer {
    height: 90vh;
}

/* Info icon for header tooltip */
#infoIcon {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s, box-shadow 0.2s;
}

#infoIcon:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Tooltip styles */
.tooltip {
    position: absolute;
    top: 45px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.98);
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    max-width: 90%;
    text-align: center;
    font-size: 13px;
    line-height: 1.4;
    border: 2px solid #667eea;
}

.tooltip.hidden {
    display: none;
}

.tooltip p {
    margin: 4px 0;
}

.tooltip strong {
    color: #667eea;
    font-size: 15px;
}

/* Score display */
#scoreDisplay {
    position: absolute;
    top: 8px;
    right: 8px;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    padding: 8px 16px;
    border-radius: 20px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: bold;
}

.score-label {
    font-size: 13px;
    color: #333;
}

#scoreValue {
    font-size: 18px;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* Sound toggle */
#soundToggle {
    position: absolute;
    top: 8px;
    right: 120px;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}

#soundToggle:hover {
    transform: scale(1.1);
}

#soundToggle.muted::after {
    content: '🔇';
    position: absolute;
}

#soundToggle.muted {
    font-size: 0;
}

/* Game area */
#gameArea {
    width: 100%;
    height: calc(100% - 35px);
    padding: 45px 15px 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Story panel */
#storyPanel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: flex;
    gap: 12px;
    align-items: center;
    min-height: 90px;
}

#characterAvatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FF6B9D, #C06C84);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

#storyText {
    flex: 1;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
}

/* Response area */
#responseArea {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#responsePrompt {
    text-align: center;
    font-size: 15px;
    font-weight: bold;
    color: #333;
    background: rgba(255, 255, 255, 0.8);
    padding: 8px;
    border-radius: 10px;
}

/* Response cards */
#responseCards {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    padding: 8px;
}

.response-card {
    background: linear-gradient(135deg, #FFF, #F0F0F0);
    border: 3px solid #667eea;
    border-radius: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
    font-size: 13px;
    text-align: center;
    min-width: 140px;
    max-width: 200px;
    position: relative;
}

.response-card:hover {
    transform: translateY(-4px) scale(1.03);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
    border-color: #FFD700;
}

.response-card.selected {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    border-color: #FF6B9D;
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(255, 107, 157, 0.5);
}

.response-card.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

/* Drop zones */
#dropZones {
    display: flex;
    gap: 10px;
    height: 120px;
}

.drop-zone {
    flex: 1;
    border: 3px dashed #999;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.5);
    display: flex;
    flex-direction: column;
    transition: all 0.3s;
}

.drop-zone.drag-over {
    background: rgba(255, 215, 0, 0.3);
    border-color: #FFD700;
    transform: scale(1.02);
}

.zone-header {
    padding: 8px;
    text-align: center;
    font-weight: bold;
    font-size: 13px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px 8px 0 0;
}

.zone-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
}

#helpfulZone .zone-header {
    color: #4CAF50;
}

#unhelpfulZone .zone-header {
    color: #F44336;
}

/* Feedback panel */
#feedbackPanel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.98);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    text-align: center;
    max-width: 85%;
    z-index: 200;
    animation: popIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes popIn {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

#feedbackIcon {
    font-size: 48px;
    margin-bottom: 12px;
}

#feedbackText {
    font-size: 15px;
    line-height: 1.6;
    color: #333;
    margin-bottom: 15px;
}

/* Action buttons */
#actionButtons {
    display: flex;
    gap: 10px;
    justify-content: center;
    padding: 8px;
}

.action-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 25px;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s;
    white-space: nowrap;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.action-btn:active {
    transform: translateY(0);
}

.action-btn.secondary {
    background: linear-gradient(135deg, #95a5a6, #7f8c8d);
}

/* Progress bar */
#progressBar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 35px;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.2);
}

#progressFill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    transition: width 0.5s ease;
    width: 0%;
}

#progressText {
    position: relative;
    z-index: 1;
    font-size: 13px;
    font-weight: bold;
    color: #333;
}

/* Results screen */
#resultsScreen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
}

#resultsContent {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    text-align: center;
    max-width: 90%;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

#resultsContent h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 22px;
}

#finalScore {
    font-size: 36px;
    font-weight: bold;
    color: #FFD700;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

#heroRank {
    font-size: 18px;
    color: #FF6B9D;
    margin-bottom: 15px;
    font-weight: bold;
}

#encouragementMessage {
    font-size: 14px;
    color: #333;
    margin-bottom: 20px;
    line-height: 1.6;
}

/* Hidden class */
.hidden {
    display: none !important;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 600px) {
    #storyPanel {
        padding: 12px;
        min-height: 80px;
    }
    
    #characterAvatar {
        width: 50px;
        height: 50px;
        font-size: 28px;
    }
    
    #storyText {
        font-size: 12px;
    }
    
    .response-card {
        min-width: 120px;
        font-size: 12px;
        padding: 10px 12px;
    }
}

/* Touch-friendly interactions */
@media (hover: none) and (pointer: coarse) {
    .response-card,
    .action-btn,
    #infoIcon,
    #soundToggle {
        min-height: 44px;
        min-width: 44px;
    }
}